#!/bin/bash

set -o errexit

echo "#5 budo-common/docker/build-image-combiner/build.sh"

echo "#7 build.sh whoami = $(whoami), pwd = $(pwd), HOME = ${HOME}"

ls -alh


DIR="$( cd "$( dirname "$0" )" && pwd )"
echo "DIR = ${DIR}"


cd $DIR

echo "#17 build.sh whoami = $(whoami), pwd = $(pwd), HOME = ${HOME}"
ls -alh

git log --graph -9


cd ../../../

pwd && ls -alh

cd image-combiner

echo "#27 build.sh whoami = $(whoami), pwd = $(pwd), HOME = ${HOME}"
ls -alh

git log --graph -9


# 回到这里
cd $DIR


echo "#18 build.sh before docker build"

docker build . -t docker-image-combiner-build

echo "#22 build.sh after docker build"

cd ../../.. && pwd && ls -alh
ROOT=$(pwd)
echo "#26 ROOT = ${ROOT}"

# 用docker构建项目
docker run \
    --privileged=true \
    --rm \
    -v $ROOT:/www/ \
    -v /data/docker/docker-maven-m2:/root/.m2 \
    -v /data/docker/docker-maven-local-repository:/usr/local/repository \
    -v /data/docker/docker-maven-settings.xml:/usr/share/maven/conf/settings.xml \
    -v $DIR/entrypoint-build.sh:/entrypoint-build.sh \
    docker-image-combiner-build

echo "#39 build.sh after docker run"

pwd && ls -al

cd target && pwd && ls -alh

echo "#43 end build.sh image-combiner"
